#ifndef ISPPAGE_H
#define ISPPAGE_H

#if _MSC_VER > 1000
#pragma once
#endif // _MSC_VER > 1000

#include "PropPage.h"
#include "ExListViewCtrl.h"
#include "../client/File.h"
#include "../client/UpdateManager.h"

class ISPPage : public CPropertyPage<IDD_ISP>, public PropPage, private UpdateManagerListener
{
public:
	ISPPage(SettingsManager *s) : PropPage(s) { 
		SetTitle(CTSTRING(SETTINGS_ISP));
		UpdateManager::getInstance()->addListener(this);
	};

	virtual ~ISPPage() { 
		ctrlISP.Detach();
		UpdateManager::getInstance()->removeListener(this);
	};

	BEGIN_MSG_MAP(ISPPage)
		MESSAGE_HANDLER(WM_INITDIALOG, onInitDialog)
		COMMAND_ID_HANDLER(IDC_ADD_ISP, onAddISP)
		COMMAND_ID_HANDLER(IDC_REMOVE_ISP, onRemoveISP)
		COMMAND_ID_HANDLER(IDC_CHANGE_ISP, onChangeISP)
		COMMAND_ID_HANDLER(IDC_RELOAD_ISPS, onReload)
		NOTIFY_HANDLER(IDC_ISP, NM_DBLCLK, onDblClick)
		NOTIFY_HANDLER(IDC_ISP, NM_CUSTOMDRAW, onCustomDraw)
	END_MSG_MAP()

	LRESULT onInitDialog(UINT, WPARAM, LPARAM, BOOL&);

	LRESULT onAddISP(WORD /*wNotifyCode*/, WORD /*wID*/, HWND /*hWndCtl*/, BOOL& /*bHandled*/);
	LRESULT onChangeISP(WORD /*wNotifyCode*/, WORD /*wID*/, HWND /*hWndCtl*/, BOOL& /*bHandled*/);
	LRESULT onRemoveISP(WORD /*wNotifyCode*/, WORD /*wID*/, HWND /*hWndCtl*/, BOOL& /*bHandled*/);
	LRESULT onReload(WORD /*wNotifyCode*/, WORD /*wID*/, HWND /*hWndCtl*/, BOOL& /*bHandled*/);
	LRESULT onCustomDraw(int /*idCtrl*/, LPNMHDR pnmh, BOOL& bHandled);

	LRESULT onDblClick(int /*idCtrl*/, LPNMHDR /* pnmh */, BOOL& bHandled) {
		return onChangeISP(0, 0, 0, bHandled);
	}

	// Common PropPage interface
	PROPSHEETPAGE *getPSP() { return (PROPSHEETPAGE *)*this; }
	virtual void write();
	
protected:
	ExListViewCtrl ctrlISP;
	static TextItem texts[];

private:
	void reload();
	string downBuf;
	virtual void on(UpdateManagerListener::Types type, int file) throw(){
		if( type == UpdateManagerListener::COMPLETE && file == UpdateManager::ISP ){
			reload();
		}
	}
};

#endif //ISPPAGE_H

/**
 * @file
 * $Id: ISPPage.h 304 2005-08-19 16:08:13Z sulan $
 */